CC = gcc
AR = ar
LD = ld

LIB_STATIC = random.a
LIB_SHARED = random.so

OBJ = random

#地址无关
CFLAGS += -fPIC  
SHAREFLAGS += -shared

all: $(LIB_STATIC) $(LIB_SHARED) $(OBJ)

OBJS = $(patsubst %.c,%.o,$(wildcard *.c))

$(OBJ) : $(OBJS)
	$(CC) -o $@ $^
	
%.o : %.c
	$(CC) $(CFLAGS) -c -o $@ $^
	
$(LIB_STATIC) : $(OBJS)
	$(AR) rcs $@ $^

$(LIB_SHARED) : $(OBJS)
	$(LD) $(SHAREFLAGS) -o $@ $^
	
clean:
	rm *.a *.so *.o $(OBJ)
